query
SELECT * FROM posts
WHERE is_published == 1 AND (category = 'Laravel' OR viewer > 50)
using model
$posts = Post::select("*")
->where("is_published", 1)
->where(function($query) {
$query->where('category', 'Laravel')
->orWhere('viewer', '>', 100);
})
->get();
query
SELECT * FROM posts
WHERE viewer > 100 OR (category = 'Laravel' AND viewer > 50)
using model
$posts = Post::select("*")
->where("viewer", ">", 100)
->orWhere(function($query) {
$query->where('category', 'Laravel')
->where('viewer', '>', 50);
})
->get();